// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/equipment/api/AssetManageApi'

import ComClass from '@api/ComQuery'
import ListClass from '@api/equipment/model/AssetListQueryReq'
import BaseClass from '@api/equipment/model/AssetDto'
import TagClass from '@api/base/model/DeviceLabelDto'
import InfoClass from '@api/equipment/model/AssetCountByStatusReq'

const CLIENT = CORE.grpcCLIENT(Client)
const COM = [ComClass, 'comQuery']
const TAG = [TagClass, 'assetLabelDtos', 1]

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  async getInfo(infoParam, TIP = `查询${CORE.MAP.ASSET}统计`) {
    const DTO = CORE.grpcDTO(InfoClass, infoParam)
    const resp = await CORE.grpc(TIP, CLIENT, 'countAssetByStatus', DTO)
    return resp.countFormDto || []
  },

  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = `查询${CORE.MAP.ASSET}列表`) {
    const DTO = CORE.grpcDTO(ListClass, param, COM, [BaseClass, 'assetInfo'], TAG)
    DTO.setStatus(param.statusList)
    const resp = await CORE.grpc(TIP, CLIENT, 'queryAssetList', DTO)
    return [resp.comQuery.totalCount, resp.assetInfoList || [], resp.map || {}]
  },
}
